{% extends "base.html" %}

{% block title %}{% if page %}编辑 {{ page.title }}{% else %}创建新页面{% endif %} - Wiki{% endblock %}

{% block content %}
<div class="container mt-4">
    <h1>{% if page %}编辑 {{ page.title }}{% else %}创建新Wiki页面{% endif %}</h1>
    
    <form method="POST">
        <div class="mb-3">
            <label for="title" class="form-label">标题</label>
            <input type="text" class="form-control" id="title" name="title" 
                   value="{{ page.title if page }}" required>
        </div>
        
        <div class="mb-3">
            <label for="content" class="form-label">内容 (支持Markdown格式)</label>
            <textarea class="form-control" id="content" name="content" 
                      rows="15" required>{{ page.content if page }}</textarea>
        </div>
        
        <div class="d-flex justify-content-between">
            <a href="{% if page %}{{ url_for('view_wiki_page', page_title=page.title) }}{% else %}{{ url_for('wiki_index') }}{% endif %}" 
               class="btn btn-outline-secondary">
                <i class="fas fa-times"></i> 取消
            </a>
            <button type="submit" class="btn btn-primary">
                <i class="fas fa-save"></i> 保存
            </button>
        </div>
    </form>
</div>
{% endblock %}
